<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: bobo
  Date: 16-11-3
  Time: 下午3:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <jsp:include page="../layout/head.jsp" >
        <jsp:param name="title" value="文章" />
    </jsp:include>
<style>
    h1{
        text-align: center;
    }
</style>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 文章查看</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div>
        <h1>${topic.title}</h1>
        <span> 类别：${topic.category.name} </span><br>
        标签：<c:forEach items="${topic.tags}" var="tag">
                <span> ${tag.name} &nbsp;</span>
            </c:forEach><br>
    <span>创建时间${topic.createTime}</span>
    <span> 更新时间${topic.updateTime}</span>
        作者：${topic.user.name}
    <span> 点击量${topic.hits} </span><br>


        <p>${topic.content}</p><br>


        <form action="${pageContext.request.contextPath}/admin/topic/ope" method="post">
            <input type="hidden" name="id" value="${topic.id}">
            状态:
            <select name="status">
                <option value="0" ${topic.status ==0 ?"selected":""}>待审核</option>
                <option value="1" ${topic.status ==1 ?"selected":""}>通过</option>
                <option value="3" ${topic.status ==3 ?"selected":""}>未通过</option>
            </select>
            <br>
            审核意见<input type="text" name="review" value="${topic.review}"><br>
            <input type="submit" value="提交">
        </form>
        <input type="button" value="设为置顶" onclick="ttop(${topic.id})">
        <input type="button" value="设为推荐" onclick="recommend(${topic.id})">

        <button onclick="ttop(${topic.id})">设为置顶</button>
        <button></button>



    review;
    messages;
    tags;


    </div>
</div>
<script>
    function ttop(id) {
        $.ajax({
            url:"${pageContext.request.contextPath}/admin/topic/top",
            type:"get",
            data:{"id":id},
            success:function (dd) {
                if(dd=="true"){
                    alert("操作成功");
                }else {
                    if(dd=="false"){
                        alert("操作失败");
                    }
                }
            }
        })
    }

    function recommend(id) {
        alert(id);
        $.ajax({
            url:"${pageContext.request.contextPath}/admin/topic/recommend",
            type:"get",
            data:{"id":id},
            success:function (dd) {
                if(dd=="true"){
                    alert("操作成功");
                }else {
                    if(dd=="false"){
                        alert("操作失败");
                    }
                }
            }
        })
    }


</script>
</body>
</html>
